<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.io.*,javax.servlet.*,javax.servlet.http.*" %>
<%@page import="java.sql.*"%>
<%@page import="org.edu.system.DBConnect"%>
<%
	String stu_id = (String) (session.getAttribute("UserName"));
	String sql123 = "SELECT * FROM student WHERE stu_id = '" + stu_id + "'";
	System.out.println(sql123);

	Connection con = DBConnect.getCon();
	Statement stmt = null;
	ResultSet rs = null;
	stmt = con.createStatement();
	rs = stmt.executeQuery(sql123);//执行命令
	if (rs.next())// 如果记录集非空，表明有匹配的用户ID
	{

		//正常进行
	} else {
		// 否则登录失败
		// response.sendRedirect ( "MyJsp.jsp" );
		response.sendRedirect("login_failure.jsp");
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="./bootstrap/css/bootstrap.min.css" rel="stylesheet">
<meta charset="UTF-8">
<title>学生教学评价 - 评教</title>
<script type="text/javascript">
function formSubmit(){
		if(confirm('提交成功！')){
			}
	}
</script>
</head>
<body style="width:900px; margin:0 auto;">
<br><br><br><br>
<%
	Statement sql; 
	ResultSet rs1,rs2;
	try{ 
	     String uri="jdbc:mysql://127.0.0.1/edu_system?user=root&password=123456&characterEncoding=gb2312&useSSL=false&serverTimezone=UTC";
	     con=DriverManager.getConnection(uri);
	     sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
	                            ResultSet.CONCUR_READ_ONLY);
	     String condition1 = "SELECT tc_name FROM teacher";
%>
<div>
<center>
<table><form action='evaluationServlet' method=post name=f1>
	<tr>
		<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
		<td>
			<select name="s1">
<%
		rs1=sql.executeQuery(condition1);
		ResultSetMetaData metaData1 = rs1.getMetaData();
		rs1.last();
		int rowNumber1=rs1.getRow();  //得到记录数
		rs1.beforeFirst();
	     while(rs1.next()){
	    	 String s = rs1.getString(1);
%>
	    	 <option><%= s %></option>
<%
     }	
%>
			</select>
		</td>
		<td>&nbsp;&nbsp;&nbsp;</td>
		<td>
			<select name="s2">
<%

		String condition2 = "SELECT course_name FROM course";
		rs2=sql.executeQuery(condition2);
		ResultSetMetaData metaData2 = rs2.getMetaData();
		rs2.last();
		int rowNumber2=rs2.getRow();
		rs2.beforeFirst();
	     while(rs2.next()){
	    	 String x = rs2.getString("course_name");
%>
	    	 <option><%= x %></option>
<%
    }
%>
			</select>
		</td>
		<td>
			<font size=2 color="red"><strong>&nbsp;&nbsp;&nbsp;(注意：请在选择老师和对应的课程后再进行教评！)</strong></font>
		</td>
	</tr>
</table></center>
</div>
<div>
<br>
<center>
<table>
	<tr><td>
		<textarea name='t1' cols='50' rows='10' style='OVERFLOW:visible'></textarea>
	</td></tr>
	<tr><td align="center"><br>
		<input type='submit' name='s2' class="btn btn-primary btn-sm" value='提交' onclick="formSubmit()">
	</td></tr>
</form></table></center>
</div>
<%	     con.close();
	}
	catch(SQLException e){
	     System.out.println(e);
	}
%>
</body>
</html>